package cn.fengzhilun.javase.day12;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.junit.Test;

import cn.fengzhilun.javase.day10.ex.Student;

public class TestHashCode {
	@Test
	public void test() {
		List<String> list =new ArrayList<String>();
		
		list.add("张三");
		list.add("李四");
		list.add("王五");
		
		
		Student student1 =new Student("王五",11);
		Student student2 =new Student("王五",11);
		Student student3 =new Student("王五",11);
		Student student4=student3;
		System.out.println(student1.hashCode());
		System.out.println(student2.hashCode());
		System.out.println(student3.hashCode());
		System.out.println(student4.hashCode());
	}
	@Test
	public void test2() {
		Set<String> set=new HashSet<String>();
		set.add("张三");
		set.add("李四");
		set.add("王五");
		
		System.out.println(set.size());
		for(String i:set) {
			System.out.println(i);
		}
		
		//Collections.sort(set);
		
		Iterator<String> itr = set.iterator();
		while(itr.hasNext()) {
			System.out.println(itr.next()); 
		}
		
	}
	@Test
	public void test3() {
		String s ="set get Arraylist Linklist set get ";
		
		String[] split = s.split(" ");
		System.out.println(Arrays.toString(split));
		Set<String> set=new HashSet<String>();
		for(int i=0;i<split.length;i++) {
			set.add(split[i]);
		}
		
		System.out.println(set);
	}
}
